package com.ibp.controller;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ibp.entity.AppMgr;
import com.ibp.response.DataResponse;
import com.ibp.response.FormResponse;
import com.ibp.response.SimpleResponse;
import com.ibp.service.AppMgrService;

@Controller
@RequestMapping("appMgr")
public class AppMgrController {
	
	private static Logger logger = LoggerFactory
			.getLogger(AppMgrController.class);
	
	
	@Autowired 
	AppMgrService appMgrServiceImpl;

	
	/**  																				  
	 * 删除 app 																			      
	 * @param app  															  
	 */  																				  
	@ResponseBody  																		  
	@RequestMapping("/deleteApp") 															  
	public SimpleResponse<String> deleteApp(AppMgr appMgr){  					  
		logger.info("删除app-->"+appMgr.toString());  							  
		SimpleResponse<String> response = new SimpleResponse<String>();  	
		response.setData(appMgrServiceImpl.deleteApp(appMgr)); 
		response.setSuccess(true);  													  
		return response;  																  
	}
	
	/***  																				  
	 * 修改 																			      
	 * @param app  															  
	 */  																				  
	@ResponseBody  																		  
	@RequestMapping("/updateApp")  														  
	public FormResponse<String> update(AppMgr appMgr){  					  
		logger.info("修改app-->"+appMgr.toString());  							  
		FormResponse<String> response = new FormResponse<String>();  
		response.setData(appMgrServiceImpl.updateApp(appMgr)); 
		return response;  																  
	} 
	
	/*** 																	              
	 * 新增 																			      
	 * @param app 															  
	 */  																				  
	@ResponseBody  																		  
	@RequestMapping("/addApp")  															  
	public FormResponse<String> add(AppMgr appMgr){  					  
		logger.info("新增app-->"+appMgr.toString());  							  
		FormResponse<String> response = new FormResponse<String>();  	
		response.setData(appMgrServiceImpl.addApp(appMgr));
		return response;  															      
	} 
	
	/*** 																	              
	 * 查询app列表 																			      
	 * @param app 															  
	 */
	@RequestMapping({"/getAppMgrList"})
	  @ResponseBody
	  public DataResponse<List<AppMgr>> getServiceNodes(AppMgr app)
	  {
	    logger.info("交易码查询" + app.toString());
	    DataResponse<List<AppMgr>> response = new DataResponse<List<AppMgr>>();
	    response.setData(appMgrServiceImpl.getAppMgrList(app));
	    return response;
	  }
}
